package com.hqyj.controller;


import com.hqyj.pojo.Exampaper;
import com.hqyj.pojo.Question;
import com.hqyj.service.ExampaperService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.support.SimpleTriggerContext;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

/**
 * <p>
 * 试卷表 前端控制器
 * </p>
 *
 * @author rock
 * @since 2021-11-12
 */
@RestController
@RequestMapping("/exampaper")
public class ExampaperController {

    /**
     * 注入ExampaperService 服务层接口
     * */
    @Autowired
    private ExampaperService exampaperService;

    /**
     * @Date: 2021/11/12
     * @param: exampaper: pojo
     * @return: java.util.HashMap<java.lang.String,java.lang.Object>
     * @Description: 获取所有试卷信息
     * */
    @GetMapping("/list")
    public HashMap<String, Object> select(Exampaper exampaper){
        return exampaperService.select(exampaper);
    }

    /**
     * @Date: 2021/11/16
     * @param: exampaper: 当前试卷信息以及 包含的所有题目 信息
     * @return: java.util.HashMap<java.lang.String,java.lang.Object>
     * @Description: 获取所有 题库中的 试题信息
     * */
    @PostMapping("/generatePaper")
    public HashMap<String, Object> generatePaper(@RequestBody Exampaper exampaper){
        return exampaperService.generatePaper(exampaper);
    }

    @PostMapping("/randGeneratePaper")
    public HashMap<String, Object> randGeneratePaper(@RequestBody Exampaper exampaper){
        return exampaperService.randGeneratePaper(exampaper);
    }

    /**
     * @Date: 2021/11/16
     * @param: exampaper: 当前试卷的 主键ID
     * @return: java.util.HashMap<java.lang.String,java.lang.Object>
     * @Description: 预览当前试卷的所有题目
     * */
    @GetMapping("/previewPaper")
    public HashMap<String, Object> previewPaper(Exampaper exampaper){
        return exampaperService.previewPaper(exampaper);
    }

    /**
     * @Date: 2021/11/16
     * @param: examId:
     * @return: java.util.HashMap<java.lang.String,java.lang.Object>
     * @Description:
     * */
    @PostMapping("/deletePaper")
    public HashMap<String, Object> deletePaper(@RequestBody Integer examId){
        return exampaperService.deletePaper(examId);
    }

    @GetMapping("/examination")
    public HashMap<String, Object> examination(Exampaper exampaper,Integer stuId){
        return exampaperService.examination(exampaper,stuId);
    }

}

